#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
class Solution {
public:
    int maxTotalReward(vector<int>& rewardValues) {
        sort(rewardValues.begin(), rewardValues.end());
        int n = rewardValues.size();
        vector<int> ans(2 * rewardValues[n - 1],0);
        ans[0]= 1;
        for (int i = 0; i < n; ++i) {
            for (int j = 2 * rewardValues[i] - 1; j >= rewardValues[i]; --j) {
                if (ans[j - rewardValues[i]])
                    ans[j] = 1;
            }
        }
        for (int i = 2 * rewardValues[n - 1] - 1; i >= 0; --i)
            if (ans[i])
                return i;
        return 0;
    }
};
int main() {
    vector<int> ans{ 1,6,4,3,2 };
    Solution().maxTotalReward(ans);
}